package com.bwie.controller;
import com.bwie.pojo.Active;
import com.bwie.service.ActiveService;
import com.bwie.service.impl.ActiveServiceImpl;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

/**
* 抽奖活动表(tb_active)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/winner/active")
public class ActiveController {
/**
* 服务对象
*/
    @Autowired
    private ActiveService activeService;

    @ApiOperation("active列表")
    @PostMapping("/activeList")
    public R activeList(@RequestBody PageInfoVo pageInfoVo){
        return activeService.activeList(pageInfoVo);
    }

    @ApiOperation("添加抽奖活动")
    @PostMapping("/addActive")
    public R addActive(@RequestBody @Validated Active active){
        return activeService.addActive(active);
    }

    @ApiOperation("用户参与活动")
    @PostMapping("/joinActive/{activeId}")
    public R joinActive(@PathVariable Integer activeId){
        return activeService.joinActive(activeId);
    }

    @ApiOperation("查看抽奖记录")
    @PostMapping("/getJoinRecord")
    public R getJoinRecord(@RequestBody PageInfoVo pageInfoVo){
        return activeService.getJoinRecord(pageInfoVo);
    }

    @ApiOperation("根据活动ID获取活动的信息")
    public R getActiveById(@PathVariable("activeId")Integer activeId){
        return activeService.getActiveById(activeId);
    }

    @ApiOperation("用户积分抽奖（分布式锁）")
    @PostMapping("/joinActiveByScore/{activeId}")
    public R joinActiveByScore(@PathVariable("activeId")Integer activeId){
        return activeService.joinActiveByScore(activeId);
    }
}
